package com.webchat.chat.service.impl;

import com.webchat.chat.dao.TenantMapper;
import com.webchat.chat.model.Tenant;
import com.webchat.chat.service.TenantService;
import com.webchat.chat.core.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by admin on 2018-06-29.
 */
@Service
@Transactional
public class TenantServiceImpl extends AbstractService<Tenant> implements TenantService {
    @Resource
    private TenantMapper tenantMapper;

    @Override
    public void deleteTenantById(String id) {
        List<Tenant> tenants = tenantMapper.selectByIds(id);
        tenants.forEach( tenant -> {
            tenant.setEnable(false);
            tenantMapper.updateByPrimaryKey(tenant);
        });
    }
}
